import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex)

function initUser() {
  return JSON.parse(localStorage.getItem('user'));
}

const store = new Vuex.Store({
  state: {
    loginFormVisible: false,
    registerFormVisible: false,
    user: initUser(),
    asideMenuState: true,
    userTypeList: [
      {value: 1, label: "管理员", jurisdiction: '增删员工'},
      {value: 2, label: "快递员", jurisdiction: '订单处理'},
      {value: 3, label: "普通用户", jurisdiction: '收发快递'},
    ],
    pkgStateList: [
      {value: 0, label: "全部"},
      {value: 1, label: "已提交"},
      {value: 2, label: "正在揽收"},
      {value: 3, label: "正在运输"},
      {value: 4, label: "正在派送"},
      {value: 5, label: "已签收"}
    ],
    provinceList: [
      {value: 0, label: "全国"},
      {value: 11, label: "北京市"}, {value: 12, label: "天津市"},
      {value: 13, label: "河北省"}, {value: 14, label: "山西省"},
      {value: 15, label: "内蒙古自治区"},
      {value: 16, label: "辽宁省"}, {value: 22, label: "吉林省"},
      {value: 23, label: "黑龙江省"},
      {value: 31, label: "上海市"}, {value: 32, label: "江苏省"},
      {value: 33, label: "浙江省"}, {value: 34, label: "安徽省"},
      {value: 35, label: "福建省"}, {value: 36, label: "江西省"},
      {value: 37, label: "山东省"},
      {value: 41, label: "河南省"}, {value: 42, label: "湖北省"},
      {value: 43, label: "湖南省"}, {value: 44, label: "广东省"},
      {value: 45, label: "广西壮族自治区"}, {value: 46, label: "海南省"},
      {value: 50, label: "重庆市"}, {value: 51, label: "四川省"},
      {value: 52, label: "贵州省"}, {value: 53, label: "云南省"},
      {value: 54, label: "西藏自治区"},
      {value: 61, label: "陕西省"}, {value: 62, label: "甘肃省"},
      {value: 63, label: "青海省"}, {value: 64, label: "宁夏回族自治区"},
      {value: 65, label: "新疆维吾尔自治区"},
      {value: 71, label: "台湾省"},
      {value: 81, label: "香港特别行政区"}, {value: 82, label: "澳门特别行政区"}
    ],
  },
  mutations: {
    loginForm(state) {
      state.loginFormVisible = !state.loginFormVisible
    },
    registerForm(state) {
      state.registerFormVisible = !state.registerFormVisible
    },
    setUser(state, user) {
      state.user = user
      localStorage.setItem('user', JSON.stringify(user))
    },
    changeAsideMenu(state, bool) {
      state.asideMenuState = bool;
      // console.log(this.state.asideMenuState)
    }
  },
})
export default store